import { App } from './App';
import { Header } from '../componets/header';
import { Footer } from '../componets/footer';
import tools from '../utils/tools';
import { DetailBoard } from '../componets/detail_board';
import { DetailModel } from '../models/detail';

class Detail extends App {
  constructor () {
    super({
      swiper: false,
      phone: true,
      field: true
    });
    this.phoneId = tools.getUrlQueryValue('id');
  }
  async render () {
    const data = await this.getPhoneData(this.phoneId);
    new Header(this.$app, this.cache.filedDatas, this.cache.phoneDatas).init();
    // new DetailBoard(this.$app, this.getPhoneData(this.phoneId)).init();
    new DetailBoard(this.$app, data).init();
    new Footer(this.$app).init();
    $('body').prepend(this.$app);
  }
  getPhoneData (id) {
    // return this.cache.phoneDatas.find(item => item.id === id)
    const detailModel = new DetailModel();
    return detailModel.getPhoneInfo(id)
  }
}
new Detail();